package yue.shen.android.demo.activity

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import yue.shen.android.demo.R

class Demo1Style1Item(itemView: View) : RecyclerView.ViewHolder(itemView) {

    private val imageView = itemView.findViewById<ImageView>(R.id.image_view)

    private val textView = itemView.findViewById<TextView>(R.id.text_view)

    fun bindData(text: String, position: Int) {
        textView.text = text
        if (position % 2 == 0) {
            imageView.setBackgroundColor(itemView.context.resources.getColor(android.R.color.holo_red_dark))
        } else {
            imageView.setBackgroundColor(itemView.context.resources.getColor(android.R.color.holo_blue_dark))
        }
    }

}